package com.glodon.paas.account.security.oauth1.provider.store.impl;


import static org.junit.Assert.*;

import java.util.UUID;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.glodon.paas.account.api.bean.Consumer;
import com.glodon.paas.account.dao.OAuthConsumerDao;
import com.glodon.paas.account.dao.domain.ConsumerEntity;
import com.glodon.paas.util.UUIDUtil;

/**
 * @author Don Li
 */
@Ignore
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring-config-test.xml")
public class OAuthConsumerDBStoreIT {

    @Autowired
    private OAuthConsumerDao store;

    @Test
    public void createConsumerTest() throws Exception {
        ConsumerEntity consumer = new ConsumerEntity();
        consumer.setConsumerkey("6BA23B39-E556-49DE-BBA8-AD3D5BCF839C");
        consumer.setConsumerSecrect("B049853C-D6FA-40BC-BE41-31C8DB504085");
        consumer.setDescription("Sample Desktop Client");
        consumer.setId(UUIDUtil.getUUIDStr());
        store.insert(consumer);
        assertNotNull(store.readConsumer("6BA23B39-E556-49DE-BBA8-AD3D5BCF839C"));
    }
    
//TODO: jmockit only works with VM parameter "-javaagent:{path}/jmockit-0.999.17.jar" 

//    @Injectable
//    private OAuthConsumerDBStore mockStore;
//
//    @Test
//    public void test() {
//        final Consumer document = new Consumer();
//        document.setConsumerkey("glodonDocumentConsumer");
//        document.setConsumerSecrect("8FPDuFuhyDfZy25UXmeRNZepEiU=");
//        document.setDescription("Glodon Document");
//        document.setCallbackURL("http://localhost:8080/document/callback");
//        new Expectations() {
//            {
//                mockStore.save(document);
//                times = 1;
//            }
//        };
//
//        mockStore.save(document);
//    }
}
